/**
 * 
 */
package it.rainbowbreeze.polygen.data;

import java.util.ArrayList;

import it.rainbowbreeze.polygen.common.LogFacility;
import it.rainbowbreeze.polygen.domain.ListItem;

/**
 * @author rainbowbreeze
 *
 */
public class ItemsDao {
    private final static String LOG_HASH = ItemsDao.class.getSimpleName(); 
    
    private final ArrayList<ListItem> mItems;
    private final LogFacility mLogFacility;
    
    public ItemsDao(LogFacility logFacility) {
        mLogFacility = logFacility;
        mItems = new ArrayList<ListItem>();
        createItems(mItems);
    }

    public ListItem getItem(long itemId) {
        mLogFacility.v(LOG_HASH, "Getting item with id " + itemId);
        for(ListItem item : mItems) {
            if (itemId == item.getId()) return item;
        }
        mLogFacility.v(LOG_HASH, "Item not found");
        return null;
    };
    
    public ArrayList<ListItem> getChildItems(long parentId) {
        mLogFacility.v(LOG_HASH, "Getting all items for parent id " + parentId);
        ArrayList<ListItem> extracted = new ArrayList<ListItem>();
        for(ListItem item : mItems) {
            if (parentId == item.getParentId()) {
                extracted.add(item);
            }
        }
        mLogFacility.v(LOG_HASH, "Found " + extracted.size() + " items");
        return extracted;
    }

    
    private void createItems(ArrayList<ListItem> items) {
        ListItem item;

        //Categorie
        //mItems.add(new ListItem(1100, 0, "NomeCategoria"));
        
        
        mItems.add(new ListItem(100, 0, "Costume"));
        mItems.add(new ListItem(200, 0, "Cultura"));
        mItems.add(new ListItem(300, 0, "Esteri"));
        mItems.add(new ListItem(400, 0, "Spettacolo"));
        mItems.add(new ListItem(500, 0, "Politica"));
        mItems.add(new ListItem(600, 0, "Pubblicità"));
        mItems.add(new ListItem(700, 0, "Rubriche"));
        mItems.add(new ListItem(800, 0, "Sport"));
        mItems.add(new ListItem(900, 0, "Tecnologie"));
        mItems.add(new ListItem(1000, 0, "Dedicate a..."));

       


        // Sottocategorie
        // Esempio mItems.add(new ListItem(201, 200, "NomeSottoCategoria", "URL"));
        
        //Costume
        mItems.add(new ListItem(101, 100, "Cani pericolosi", "http://www.polygen.org/polygen/remote/ita/canipericolosi.grm"));
        mItems.add(new ListItem(102, 100, "Calciatori", "http://www.polygen.org/polygen/remote/ita/calciatori.grm"));
        mItems.add(new ListItem(103, 100, "Coatti", "http://www.polygen.org/polygen/remote/ita/coatti.grm"));
        mItems.add(new ListItem(104, 100, "Cocktail", "http://www.polygen.org/polygen/remote/ita/cocktail.grm"));
        mItems.add(new ListItem(105, 100, "Disclaimer", "http://www.polygen.org/polygen/remote/ita/disclaimer.grm"));
        mItems.add(new ListItem(106, 100, "Fantasy", "http://www.polygen.org/polygen/remote/ita/fantasyfanfiction.grm"));
        mItems.add(new ListItem(107, 100, "Gestionale", "http://www.polygen.org/polygen/remote/ita/gestionale.grm"));
        mItems.add(new ListItem(108, 100, "IDAG", "http://www.polygen.org/polygen/remote/ita/idag.grm"));
        mItems.add(new ListItem(109, 100, "Insulti", "http://www.polygen.org/polygen/remote/ita/insulti.grm"));
        mItems.add(new ListItem(110, 100, "Kassander", "http://www.polygen.org/polygen/remote/ita/kassander.grm"));
        mItems.add(new ListItem(111, 100, "Miss Sarajevo", "http://www.polygen.org/polygen/remote/ita/misssarajevo.grm"));
        mItems.add(new ListItem(112, 100, "Nobiltà", "http://www.polygen.org/polygen/remote/ita/nobilta.grm"));
        mItems.add(new ListItem(113, 100, "Ordinazione", "http://www.polygen.org/polygen/remote/ita/ordinazione.grm"));
        //mItems.add(new ListItem(114, 100, "Pornsite", "http://www.polygen.org/polygen/remote/eng/pornsite.grm")); //<a href.....
        mItems.add(new ListItem(115, 100, "Studio Aperto", "http://www.polygen.org/polygen/remote/ita/studioaperto.grm"));
        mItems.add(new ListItem(116, 100, "Teen", "http://www.polygen.org/polygen/remote/ita/teen.grm"));
        mItems.add(new ListItem(117, 100, "Teen II", "http://www.polygen.org/polygen/remote/ita/teen2.grm"));
        mItems.add(new ListItem(118, 100, "Trial", "http://www.polygen.org/polygen/remote/ita/trial.grm"));


        //Cultura
        //mItems.add(new ListItem(201, 200, "Artex", "http://www.polygen.org/polygen/remote/eng/artex.grm"));
        mItems.add(new ListItem(202, 200, "Biografia", "http://www.polygen.org/polygen/remote/ita/bio.grm"));
        mItems.add(new ListItem(203, 200, "Dan Brown", "http://www.polygen.org/polygen/remote/ita/danbrown.grm"));
        mItems.add(new ListItem(204, 200, "Dizionario", "http://www.polygen.org/polygen/remote/ita/diz.grm"));
        mItems.add(new ListItem(205, 200, "Epigrafi", "http://www.polygen.org/polygen/remote/ita/epigrafi.grm"));
        //mItems.add(new ListItem(206, 200, "Gleba", "http://www.polygen.org/polygen/remote/ita/gleba.grm"));
        mItems.add(new ListItem(207, 200, "Grandeur", "http://www.polygen.org/polygen/remote/fra/grandeur.grm"));
        mItems.add(new ListItem(208, 200, "Ghezzi", "http://www.polygen.org/polygen/remote/ita/ghezzi.grm"));
        mItems.add(new ListItem(209, 200, "Haiku", "http://www.polygen.org/polygen/remote/ita/haiku.grm"));
        mItems.add(new ListItem(210, 200, "Melissa P.", "http://www.polygen.org/polygen/remote/ita/melissap.grm"));
        mItems.add(new ListItem(211, 200, "Ordini Religiosi", "http://www.polygen.org/polygen/remote/ita/ordinireligiosi.grm"));
        mItems.add(new ListItem(212, 200, "Proverbi", "http://www.polygen.org/polygen/remote/ita/prov.grm"));
        mItems.add(new ListItem(213, 200, "Recensioni Libri", "http://www.polygen.org/polygen/remote/ita/recensionilibri.grm"));
        mItems.add(new ListItem(214, 200, "Sagra", "http://www.polygen.org/polygen/remote/ita/sagra.grm")); //2&186 da parsare
        mItems.add(new ListItem(215, 200, "Zen", "http://www.polygen.org/polygen/remote/ita/zen.grm"));

        //Esteri
        mItems.add(new ListItem(301, 300, "Chiname", "http://www.polygen.org/polygen/remote/eng/chiname.grm"));
        mItems.add(new ListItem(302, 300, "Comuni Lombardi", "http://www.polygen.org/polygen/remote/ita/comunilombardi.grm"));
        mItems.add(new ListItem(303, 300, "Fernanda", "http://www.polygen.org/polygen/remote/eng/fernanda.grm"));
        mItems.add(new ListItem(304, 300, "Maremma Maiala", "http://www.polygen.org/polygen/remote/ita/maremmamaiala.grm"));
        mItems.add(new ListItem(305, 300, "Nico", "http://www.polygen.org/polygen/remote/ita/nico.grm"));
        mItems.add(new ListItem(306, 300, "Nipponame", "http://www.polygen.org/polygen/remote/eng/nipponame.grm"));
        mItems.add(new ListItem(307, 300, "Nomi Emiliani", "http://www.polygen.org/polygen/remote/ita/nomiemiliani.grm"));
        mItems.add(new ListItem(308, 300, "Ristoranti cinesi", "http://www.polygen.org/polygen/remote/ita/ristoranticinesi.grm"));

        //Spettacolo
        //mItems.add(new ListItem(401, 400, "Action", "http://www.polygen.org/polygen/remote/ita/action.grm"));
        mItems.add(new ListItem(402, 400, "Antani", "http://www.polygen.org/polygen/remote/ita/antani.grm"));
        //mItems.add(new ListItem(403, 400, "B-Film"    , "http://www.polygen.org/polygen/remote/ita/b-film.grm")); //offline?
        mItems.add(new ListItem(404, 400, "Beautiful", "http://www.polygen.org/polygen/remote/ita/beautiful.grm"));
        mItems.add(new ListItem(405, 400, "Boyband", "http://www.polygen.org/polygen/remote/eng/boyband.grm"));
        mItems.add(new ListItem(406, 400, "Cartoons", "http://www.polygen.org/polygen/remote/ita/cartoons.grm"));
        //mItems.add(new ListItem(407, 400, "Chiquito y Paquito", "http://www.polygen.org/polygen/remote/ita/chicoypaco.grm"));
        mItems.add(new ListItem(408, 400, "Fiera dell'est", "http://www.polygen.org/polygen/remote/ita/fiera.grm"));
        mItems.add(new ListItem(409, 400, "GATA", "http://www.polygen.org/polygen/remote/ita/gata.grm"));
        mItems.add(new ListItem(410, 400, "Hollywood", "http://www.polygen.org/polygen/remote/ita/hollywood.grm"));
        //mItems.add(new ListItem(411, 400, "Housemusic", "http://www.polygen.org/polygen/remote/ita/housemusic.grm"));
        //mItems.add(new ListItem(412, 400, "Manback", "http://www.polygen.org/polygen/remote/ita/manback.grm"));
        mItems.add(new ListItem(413, 400, "Metal", "http://www.polygen.org/polygen/remote/eng/metal.grm"));
        mItems.add(new ListItem(414, 400, "Mike", "http://www.polygen.org/polygen/remote/ita/mike.grm"));
        mItems.add(new ListItem(415, 400, "Rappaz", "http://www.polygen.org/polygen/remote/eng/rappaz.grm"));
        //mItems.add(new ListItem(416, 400, "Recensioni Indie", "http://www.polygen.org/polygen/remote/ita/recensioniindie.grm")); //</i> </b>
        //mItems.add(new ListItem(417, 400, "Star Trek", "http://www.polygen.org/polygen/remote/ita/startrek.grm"));
        mItems.add(new ListItem(418, 400, "Telefilm", "http://www.polygen.org/polygen/remote/ita/telefilm.grm"));
        //mItems.add(new ListItem(419, 400, "Ufo Robot", "http://www.polygen.org/polygen/remote/ita/uforobot.grm"));
        //mItems.add(new ListItem(420, 400, "Verdena", "http://www.polygen.org/polygen/remote/ita/verdena.grm"));

        //Politica
        //mItems.add(new ListItem(501, 500, "Blocchi del traffico", "http://www.polygen.org/polygen/remote/ita/bloccotraffico.grm"));
        mItems.add(new ListItem(502, 500, "Contursi Terme", "http://www.polygen.org/polygen/remote/ita/contursi.grm"));
        mItems.add(new ListItem(503, 500, "Dux", "http://www.polygen.org/polygen/remote/ita/dux.grm"));
        mItems.add(new ListItem(504, 500, "Flavia Vento", "http://www.polygen.org/polygen/remote/ita/flavia.grm"));
        mItems.add(new ListItem(505, 500, "Girotondi", "http://www.polygen.org/polygen/remote/ita/girotondi.grm"));
        mItems.add(new ListItem(506, 500, "Piani sanitari", "http://www.polygen.org/polygen/remote/ita/piani.grm"));
        mItems.add(new ListItem(507, 500, "Poster", "http://www.polygen.org/polygen/remote/ita/poster.grm"));
        mItems.add(new ListItem(508, 500, "Silvio", "http://www.polygen.org/polygen/remote/ita/silvio.grm"));

        //Pubblicità
        mItems.add(new ListItem(601, 600, "Beghelli", "http://www.polygen.org/polygen/remote/ita/beghelli.grm"));
        mItems.add(new ListItem(602, 600, "Cavallo Goloso", "http://www.polygen.org/polygen/remote/ita/cavallogoloso.grm"));
        //mItems.add(new ListItem(603, 600, "Clerasil", "http://www.polygen.org/polygen/remote/ita/clerasil.grm"));
        mItems.add(new ListItem(604, 600, "De'Longhi", "http://www.polygen.org/polygen/remote/ita/delonghi.grm"));
        //mItems.add(new ListItem(605, 600, "Duplo", "http://www.polygen.org/polygen/remote/ita/duplo.grm"));
        mItems.add(new ListItem(606, 600, "Levissima", "http://www.polygen.org/polygen/remote/ita/levissima.grm"));
        mItems.add(new ListItem(607, 600, "Meliconi", "http://www.polygen.org/polygen/remote/ita/meliconi.grm"));
        mItems.add(new ListItem(608, 600, "MS", "http://www.polygen.org/polygen/remote/eng/ms.grm"));
        mItems.add(new ListItem(609, 600, "Payoff", "http://www.polygen.org/polygen/remote/ita/payoff.grm"));
        mItems.add(new ListItem(610, 600, "Payoff II", "http://www.polygen.org/polygen/remote/eng/payoff.grm"));
        mItems.add(new ListItem(611, 600, "Polygen", "http://www.polygen.org/polygen/remote/ita/polygen.grm"));
        mItems.add(new ListItem(612, 600, "Ponti", "http://www.polygen.org/polygen/remote/ita/ponti.grm"));
        mItems.add(new ListItem(613, 600, "Unieuro", "http://www.polygen.org/polygen/remote/ita/unieuro.grm"));

        //Rubriche
        mItems.add(new ListItem(701, 700, "Annunci", "http://www.polygen.org/polygen/remote/ita/annunci.grm"));
        mItems.add(new ListItem(702, 700, "Gourmet", "http://www.polygen.org/polygen/remote/ita/gourmet.grm"));
        mItems.add(new ListItem(703, 700, "Gusto", "http://www.polygen.org/polygen/remote/ita/gusto.grm"));
        mItems.add(new ListItem(704, 700, "Kamasutra", "http://www.polygen.org/polygen/remote/ita/kamasutra.grm"));
        //mItems.add(new ListItem(705, 700, "Lotto", "http://www.polygen.org/polygen/remote/ita/lotto.grm"));
        mItems.add(new ListItem(706, 700, "Oroscopo", "http://www.polygen.org/polygen/remote/ita/oroscopo.grm"));
        mItems.add(new ListItem(707, 700, "Ricette", "http://www.polygen.org/polygen/remote/ita/ricette.grm"));
        //mItems.add(new ListItem(708, 700, "Recensioni", "http://www.polygen.org/polygen/remote/ita/recensioni.grm"));

        //Sport
        mItems.add(new ListItem(801, 800, "Basket", "http://www.polygen.org/polygen/remote/ita/basket.grm"));
        //mItems.add(new ListItem(802, 800, "Brazil", "http://www.polygen.org/polygen/remote/ita/brazil.grm"));
        mItems.add(new ListItem(803, 800, "Biscardi", "http://www.polygen.org/polygen/remote/ita/aldo.grm"));
        mItems.add(new ListItem(804, 800, "De Zan", "http://www.polygen.org/polygen/remote/ita/dezan.grm"));
        mItems.add(new ListItem(805, 800, "Pizzul", "http://www.polygen.org/polygen/remote/ita/pizzul.grm"));


        //Tecnologie
        mItems.add(new ListItem(901, 900, "BOFH", "http://www.polygen.org/polygen/remote/ita/bofh.grm"));
        //mItems.add(new ListItem(902, 900, "Chat", "http://www.polygen.org/polygen/remote/ita/bofh.grm"));
        mItems.add(new ListItem(903, 900, "Design Patterns", "http://www.polygen.org/polygen/remote/eng/designpatterns.grm"));
        //mItems.add(new ListItem(904, 900, "Farmagen", "http://www.polygen.org/polygen/remote/ita/farmagen.grm"));
        mItems.add(new ListItem(905, 900, "Genio", "http://www.polygen.org/polygen/remote/ita/genio.grm"));
        mItems.add(new ListItem(906, 900, "Manager", "http://www.polygen.org/polygen/remote/eng/manager.grm"));
        mItems.add(new ListItem(907, 900, "OGM", "http://www.polygen.org/polygen/remote/ita/ogm.grm"));
        mItems.add(new ListItem(908, 900, "OOP", "http://www.polygen.org/polygen/remote/ita/oop.grm"));
        mItems.add(new ListItem(909, 900, "Paper", "http://www.polygen.org/polygen/remote/eng/paper.grm"));
        mItems.add(new ListItem(910, 900, "Paper II", "http://www.polygen.org/polygen/remote/eng/paper2.grm"));
        mItems.add(new ListItem(911, 900, "Professionisti", "http://www.polygen.org/polygen/remote/ita/professionisti.grm"));
        mItems.add(new ListItem(912, 900, "Secante", "http://www.polygen.org/polygen/remote/ita/secante.grm"));
        //mItems.add(new ListItem(913, 900, "The Gate", "http://www.polygen.org/polygen/remote/ita/tglog.grm")); //altro da parsare
        mItems.add(new ListItem(914, 900, "Videogames", "http://www.polygen.org/polygen/remote/eng/videogames.grm"));
        //mItems.add(new ListItem(915, 900, "World of warcraft", "http://www.polygen.org/polygen/remote/eng/wowcitychat.grm"));


        //Dedicate a..
        //mItems.add(new ListItem(1001, 1000, "Covo", "http://www.polygen.org/polygen/remote/ita/covo.grm"));
        mItems.add(new ListItem(1002, 1000, "CUG", "http://www.polygen.org/polygen/remote/ita/cug.grm"));
        mItems.add(new ListItem(1003, 1000, "Enrica", "http://www.polygen.org/polygen/remote/ita/enrica.grm"));
        mItems.add(new ListItem(1004, 1000, "Filippi", "http://www.polygen.org/polygen/remote/ita/enrica.grm"));
        mItems.add(new ListItem(1005, 1000, "Koan", "http://www.polygen.org/polygen/remote/ita/koan.grm"));
        mItems.add(new ListItem(1006, 1000, "Monte", "http://www.polygen.org/polygen/remote/ita/monte.grm"));
        mItems.add(new ListItem(1007, 1000, "Piero A", "http://www.polygen.org/polygen/remote/ita/pieroa.grm"));
        mItems.add(new ListItem(1008, 1000, "PNG", "http://www.polygen.org/polygen/remote/ita/png.grm"));
        mItems.add(new ListItem(1009, 1000, "Tormentoni", "http://www.polygen.org/polygen/remote/ita/tormentoni.grm"));
        //mItems.add(new ListItem(1010, 1000, "Vision-X", "http://www.polygen.org/polygen/remote/ita/vision-x.grm")); //offline?
        mItems.add(new ListItem(1011, 1000, "Visionbello", "http://www.polygen.org/polygen/remote/ita/visionbello.grm"));
    }
    
}
